using System.Data;
using System.Data.SqlClient;
using Provausio.Common.Data;
using Provausio.Common.Objects;

namespace TrainingManagement.api.Models.Data.CRUD.Employee
{
    public class EmployeeDeactivateDataSource : NonQuerySource<int>
    {
        public override bool Execute(int request)
        {
            const string deactivateEmployee = "dbo.training_api_EmployeeDeactivate";
            var parameters = new SqlParameter[1];
            parameters[0] = new SqlParameter("@EmployeeID", SqlDbType.Int){Value = request};
            
            return
                SqlHelper.ExecuteNonQuery(
                    ConnectionStrings.TrainingDb,
                    CommandType.StoredProcedure,
                    deactivateEmployee,
                    parameters) != 0;
        }
    }
}